
package com.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;



import com.dao.TbPictureDao;
import com.model.TbPicture;
import com.service.TbPictureService;
import com.utils.ImageUtil;
import com.utils.ResultJson;


/**
 * @描述: 接口实现类
 * @创建时间：2019-3-13上午11:24:34
 * @创建人：wls
 */
@Service
public class TbPictureServiceImpl implements TbPictureService {
	Logger logger = Logger.getLogger(this.getClass());
@Resource
private TbPictureDao tbPictureDao;
	/**
	 * @描述:图片列表获取 
	 * @创建人：wls
	 * @创建时间：2019-3-13上午11:24:34
	 * @参数： @param pageNo
	 * @参数： @param pageSize
	 * @参数： @return
	 */
	@Override
	public ResultJson selectPictures(int pageNo, int pageSize) {
		ResultJson resultJson = null;

		List<TbPicture> list = tbPictureDao.selectPictures((pageNo - 1)
				* pageSize, pageSize);
		int total = tbPictureDao.selectCount();
		resultJson = new ResultJson(100, total, list);

		return resultJson;
	
	}

	/**
	 * @throws Exception 
	 * @描述: 图片转码
	 * @创建人：wls
	 * @创建时间：2019-3-13上午11:24:34
	 * @参数： @param url
	 * @参数： @param request
	 * @参数： @return
	 */
	@Override
	public ResultJson transById(String url, HttpServletRequest request) throws Exception {
		ResultJson resultJson = null;
		logger.info(new Date().getTime());
		String message = "";
		Integer states = 100;
		String rows = null;
		ImageUtil imageUtil = new ImageUtil();
		if (StringUtils.isNotBlank(url)) {
			rows = imageUtil.getURLImage(url);
		}
		resultJson = new ResultJson(states, rows, message);
		logger.info(new Date().getTime());
		return resultJson;
	}

}
